package com.sigmazero13.bgjeeves.db;

public enum DbField {
	GAME_ID("id", "INTEGER PRIMARY KEY", 1),
	GAME_NAME("name", "TEXT", 1),
	GAME_MINPLAYERS("min_players", "INTEGER", 1),
	GAME_MAXPLAYERS("max_players", "INTEGER", 1),
	GAME_BGGLENGTH("bgg_length", "INTEGER", 1),
	GAME_BGGRATING("bgg_rating", "REAL", 1),
	GAME_MANUAL("bgg_manual", "INTEGER", 1),
	
	PLAY_ID("play_id", "INTEGER PRIMARY KEY", 1),
	PLAY_GAME_ID("game_id", "INTEGER", 1),
	PLAY_DATE("played_on", "TEXT", 1),
	PLAY_LOCATION("location", "TEXT", 4),
	PLAY_SCENARIO("scenario", "TEXT", 4),
	PLAY_LENGTH("game_length", "INTEGER", 1),
	PLAY_COMMENTS("comments", "TEXT", 5),
	
	PLAYER_ID("player_id", "INTEGER PRIMARY KEY", 1),
	PLAYER_PLAY_ID("play_id", "INTEGER", 1),
	PLAYER_NAME("player_name", "TEXT", 1),
	PLAYER_USERNAME("username", "TEXT", 1),
	PLAYER_TEAM("team", "TEXT", 1, 4),
	PLAYER_STARTINGPOS("starting_position", "INTEGER", 1),
	PLAYER_SCORE("score", "INTEGER", 1),
	PLAYER_WINNER("winner", "INTEGER", 1),
	
	CUSTOM_INFO_ID("custom_id", "INTEGER PRIMARY KEY", 4),
	CUSTOM_INFO_GAME_ID("game_id", "INTEGER", 4),
	CUSTOM_INFO_MINPLAYERS("custom_min", "INTEGER", 4),
	CUSTOM_INFO_MAXPLAYERS("custom_max", "INTEGER", 4),
	
	TEAM_ID("team_id", "INTEGER PRIMARY KEY", 5),
	TEAM_GAME_ID("game_id", "INTEGER NOT NULL", 5),
	TEAM_NAME("team_name", "TEXT", 5), 
	
	TEAM_PLAYER_ID("team_player_id", "INTEGER PRIMARY KEY", 5),
	TEAM_PLAYER_TEAM_ID("team_id", "INTEGER NOT NULL", 5),
	TEAM_PLAYER_PLAYER_ID("player_id", "INTEGER NOT NULL", 5);
	
	private String fieldName;
	private String fieldType;
	private Integer startVersion;
	private Integer stopVersion;
	
	
	private DbField(String fieldName, String fieldType, Integer startVersion, Integer stopVersion) {
		this.fieldName = fieldName;
		this.fieldType = fieldType;
		this.startVersion = startVersion;
		this.stopVersion = stopVersion;
	}
	
	private DbField(String fieldName, String fieldType, Integer startVersion) {
		this(fieldName, fieldType, startVersion, 999);
	}
	
	public String getName() {
		return fieldName;
	}
	
	public String getType() {
		return fieldType;
	}
	
	public Integer getStartVersion() {
		return startVersion;
	}
	
	public Integer getStopVersion() {
		return stopVersion;
	}
	
	public String getColumnDef() {
		return fieldName + " " + fieldType;
	}
}
